<!DOCTYPE html>
<html>
<head>
	<title>多人登录界面</title>
	<meta charset="utf-8">
	<script type="text/javascript">
	var user=null;
	  function User(account,password,name,sex,){

        this.account = account;
        this.password = password;
        this.name = name;
        this.sex = sex;
  		this.input=function(){
   		return 'id='+this.account+",password="+this.password+",name="+this.name+",sex="+this.sex+"\n";	
 		}
 }
 	function home(){
 		var key = prompt('请选择你要进行的操作！\n1.登录\n2.注册\n3.退出');
 		switch(key){
 			case'1':
 			login();
 			break;
 			case'2':
 			register() ;
            break;
            case '3':
            return;
            default:
          alert("亲,输入有误!");
          }
          home();
 	}


 	function login(){
 		 if (user==null) {
         return alert('您还没注册过,快去注册吧乖！');
       }
       		var account = prompt('请输入账号！');
            var passWord = prompt('请输入密码！');
            if (user.account!=account||passWord!=user.password) {   
                    return alert('您的账号密码输入有误！');
                  }
                  alert('登录成功！');
                  management();
 	}



 	function register(){
 		var account=prompt('请输入您的账号!');
 		 if (account=='') {
      return alert('您的账号和密码不能为空！');
    }
    	var password=prompt('请输入您的密码!');
    	var password1=prompt('请确认您的密码！');
    	 if(password==""||password != password1){
      	return alert('您两次输入的密码有问题！');
      }
      	var name = prompt('请输入您的名字!');
    	var sex = prompt('请输入您的性别!');
    		if(sex)
    	 user = new User(account,password,name,sex);
    	alert("创建成功！");
 	}








	</script>
</head>
<body>

</body>
</html>